package foodmaterial.utils;

import java.util.HashMap;
import java.util.Map;

public class FoodLock {
    private static Map<String,byte[]> lock = new HashMap<>() ;
    private static volatile FoodLock instance  ;

    private FoodLock() {
    }

    public static FoodLock getInstance(){
        if (instance == null){
            synchronized(FoodLock.class){
                if (instance == null){
                    instance = new FoodLock() ;
                }
            }
        }
        return instance;
    }

    public void addLock(String db) {
        byte[] javaLock = new byte[0] ;
        lock.put(db,javaLock) ;
    }

    public byte[] getLock(String db) {
        return lock.get(db) ;
    }
}
